home *** CD-ROM | disk | FTP | other *** search
- Path: news.indy.net!amphigory!pazuzu
- From: Pazuzu@amphigory.com (Pazuzu)
- Date: 27 Feb 96 20:16:46
- Newsgroups: comp.lang.c
- Subject: What is &Variable (declared as: char Var
- Message-ID: <13b_9602272020@amphigory.com>
- Organization: The Vision and the Void
-
- On 2/25/96 5:53PM, Fido wrote:
-
- >From: Abu Wawda
- >To: All
- >Subject: What is &Variable (declared as: char Variable[10])?
- >Date: 25 Feb 96 17:53:53
-
- >From: wawda@alcor.usc.edu (Abu Wawda)
- >Subject: What is &Variable (declared as: char Variable[10])?
- >Organization: University of Southern California, Los Angeles, CA
-
- >I'm having trouble understanding what the address of a static array
- >is. For example, if I declare a variable called myarray as:
- > char myarray[10];
- >then what could &myarray possibly mean? myarray is not a pointer, so
- >&myarray could not possibly be the address of the variable myarray
- >(like it would be if I did char* myarray and then asked for &myarray).
-
- >Functions such as scanf() allow the following:
-
- > char myarray[10];
-
- > scanf("%s",&myarray);
-
- >but I don't understand what scanf() could possibly be taking in the
- >second parameter. It can't be: char** since myarray is not a
- >pointer. I CAN understand how the following would work:
-
-
- myarray may not be a pointer (actually, it IS, but for the sake of argument...)
- but EVERYTHING, EVERYTHING, EVERYTHING has a memory address (otheriwise, it
- ain't in memory!), and &<identifier> gives you its address. myarray IS a
- pointer. All arrays are pointers.
-
- >I cannot pass &myarray if I declare it as: char myarray[10]. So how do
- >this work? Thanks in advance,
-
- >Abu Wawda
- >wawda@scf.usc.edu
-
- Yes, you can pass it. here:
-
- void func1(char *blort) {
- printf("%s", blort);
- }
-
- void func2(void) {
- char astring[81];
- strcpy(astring, "this is a test...");
- func1(&astring);
- }
-
- ---
- Pazuzu (pazuzu@amphigory.com):
- SysOp: The Vision and the Void - +1 219 583 5786 - 2400 - 28,800 24/7
- Running Excalibur & WME / BeeMail Alpha Site - h/p, Law, Drugs, Etc
- --- home page: http://www.beemail.com/pazuzu ---
- GothCode 2.0: GoCS!4Ju!3 TJt cDBRc+3M PSl(R) V++s M++ ZGo(GnPuSkInExThBm)
- C+4P15ucp a25+ n+O b:+T H180 g+T w+T r+3(-3)B D+4! h++ s10 k++BdSMDsWR Rm
- Sm N1291LS LusIN- HfsSp8
-